#include "sendcountupdater.h"
#include <QDebug>
#include <QLabel>

SendCountUpdater::SendCountUpdater(QSerialPort *serialPort, QMutex *mutex, QLabel* lbl, QObject *parent)
    : QObject(parent), m_serialPort(serialPort), m_mutex(mutex), lblSendNum(lbl)
{

}
SendCountUpdater::~SendCountUpdater()
{

}

void SendCountUpdater::updateSendCount(int data)
{
    if(data >= 0)
    {
        // 发送字节计数
        sendNum += data;
        // 状态栏显示计数值
        QString str;
        setNumOnLabel(lblSendNum, "S: ", sendNum);
        emit updateLabel(str);
    }

}
void SendCountUpdater::setNumOnLabel(QLabel* lbl, QString strS, long num)
{
    // 标签显示
    QString str = strS + QString::number(num);
    lbl->setText(str);
}
